<?php
	session_start();
	include("functions.php");
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Cambodia Job</title>
		<link href="css/bootstrap.css" rel="stylesheet"/>
		<link href="css/bootstrap-responsive.css" rel="stylesheet"/>
		<link href='css/custom.css' rel='stylesheet'/>
		<script src="js/jquery-1.9.1.js"></script>
		<script src="js/bootstrap.js"></script>
		<script>
			window.onload=function(){
				document.querySelector("ul#nav li:nth-child(4)").classList.add("active");
			};
		</script>
	</head>
	<body>
		<div class="container">
			<?php 
				if(!isset($_SESSION["userid"])){
					getHeader();
				}
				else{
			?>
				<div class='row-fluid row-header'>
				<div class='span3 text-center'>
				<a href='/cambodiajob/index.php'>
				<img src='/cambodiajob/img/logo_kh.png' alt='Khschools.com' />
				</a></div>
				<div class='span9'>
				<ul class='nav nav-pills pull-right' id='nav'>
					<li><a href='/cambodiajob/index.php' class='text-white'>Home</a></li>
					<li><a href='/cambodiajob/about.php' class='text-white'>About Us</a></li>
					<li><a href='/cambodiajob/#' class='text-white'>Contact Us</a></li>
					<li><a href="logout.php" class="text-white" id="btnlogout">Logout</a></li>
					</ul></div></div>
			<?php
				}
			?>
		</div>
		<div class='container' style='margin-top: 18px;'>
		<h3 class='text-info'>Member Section!</h3><hr/>
		<div class="row-fluid">
			<div class="span4">
				<form method="post">
					<table>
						<tr>
							<td> E-mail Address&nbsp;&nbsp;</td>
							<td><input type="email" required size="22" name="txtmail" 
								value="<?php echo @$_POST['txtmail']; ?>" /></td>
						</tr>
						<tr>
							<td>Password</td>
							<td><input type="password" required size="22" name="pass" 
								 value="<?php echo @$_POST['pass']; ?>" /></td>
						</tr>
						<tr>
							<td>Login As</td>
							<td>
								<select name="sl">
									<option value="1">Employer</option>
									<option value="0">Employee</option>
								</select>
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<input type="submit" value="Login" name="btnlogin" class="btn btn-primary" />
								<input type="reset" value="reset" name="btncancel" class="btn btn-info" />
							</td>
						</tr>
						<tr>
							<td colspan="2">
								<?php 
									if(isset($_POST['btnlogin']))
									{
										$email=$_POST['txtmail'];
										$pass = $_POST['pass'];
										$as = $_POST['sl'];
										$login = loginAs($email, $pass, $as);
										if($login=="OK")
										{
											header("location: employer/");
										}
										else{
											echo "<p id='sms' style='color:red; padding:4px; border:1px slid red'>*** " .$login. "</p>";
										}
									}
								?>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="span8">Something else...</div>
		</div>
		</div>
	</body>
</html>